﻿using System.Collections.Generic;
using System.Linq;
using DTD.Repositories.Interfaces;

namespace DTD.Repositories
{
    public class CategoryRepository: RepositoryBase, ICategoryRepository
    {
        public List<Category> GetRootCategories()
        {
            return dataContext.Categories.ToList();
        }

        public void Add(Category category)
        {
            dataContext.Categories.InsertOnSubmit(category);
            dataContext.SubmitChanges();
        }

        public string GetCategoryName(int Id)
        {
            return dataContext.Categories.Where(c => c.Id == Id).SingleOrDefault().Title;
        }
    }
}